$OpenBSD: patch-buildtools_wafsamba_wafsamba_py,v 1.3 2016/04/22 11:48:36 jca Exp $

- allow the library version to be overriden

  BUG: https://bugzilla.samba.org/show_bug.cgi?id=9774

- make sure we don't clobber the version that ends up in tdb.pc

--- buildtools/wafsamba/wafsamba.py.orig	Wed Apr 13 17:18:35 2016
+++ buildtools/wafsamba/wafsamba.py	Wed Apr 13 17:18:35 2016
@@ -217,6 +217,14 @@ def SAMBA_LIBRARY(bld, libname, source,
     deps = TO_LIST(deps)
     deps.append(obj_target)
 
+    saved_lib_version = vnum
+    osvnum = os.getenv('LIB' + libname.replace('-', '_') + '_VERSION')
+    if osvnum:
+        vnum = osvnum
+        if realname:  realname  = re.sub(r'(\.[0-9]+)+$', '.' + osvnum, realname)
+        if link_name: link_name = re.sub(r'(\.[0-9]+)+$', '.' + osvnum, link_name)
+        if soname:    soname    = re.sub(r'(\.[0-9]+)+$', '.' + osvnum, soname)
+
     realname = bld.map_shlib_extension(realname, python=(target_type=='PYTHON'))
     link_name = bld.map_shlib_extension(link_name, python=(target_type=='PYTHON'))
 
@@ -328,7 +336,7 @@ def SAMBA_LIBRARY(bld, libname, source,
         t.link_name = link_name
 
     if pc_files is not None and not private_library:
-        bld.PKG_CONFIG_FILES(pc_files, vnum=vnum)
+        bld.PKG_CONFIG_FILES(pc_files, vnum=saved_lib_version)
 
     if (manpages is not None and 'XSLTPROC_MANPAGES' in bld.env and
         bld.env['XSLTPROC_MANPAGES']):
